/*
 ============================================================================
 Name        : MulImage.h
 Author      : chenzs
 Version     : 1.0
 Copyright   : Your copyright notice
 Description : CMulImage �����첽���ļ���������ȡ��ʾ���ʽͼƬ����(jpg��png��gif��bmp�ȣ���
 ��Ҫ��ͨ��GetBitmap()��ȡ�����ж���α����δת����ɣ�����NULL����
 ʹ�ÿ⣺ fbscli.lib ; mediaclientimage.lib 
 ============================================================================
 */

#ifndef MULIMAGE_H
#define MULIMAGE_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>

#include <FBS.H>				//For CFbsBitmap,					link fbscli.lib 
#include <MdaImageConverter.h>  //For CMdaImageFileToBitmapUtility & CMdaImageDescToBitmapUtility�� link mediaclientimage.lib 
#include "WebClientEngine.h"

// CLASS DECLARATION
class CMulImage;

//����ӿ�
class MMulImageObserver
{
public:
	//�������
	virtual void MulImageReady (CMulImage *pImage ) = 0;
};

/**
 *  CMulImage
 * 
 */
class CMulImage : public CBase, MMdaImageUtilObserver, MWebClientObserver
{
public:
	// Constructors and destructor

	/**
	 * Destructor.
	 */
	~CMulImage ();

	/**
	 * Constructor for performing 1st stage construction
	 */
	CMulImage (MMulImageObserver* Observer );

	/**
	 * ͨ������ת��ͼƬ
	 */
	void
			OpenDataL (const TDesC8 &aFileName, TBool aNeedMasked = EFalse, 
					TMdaClipFormat *aFormat =0, TMdaPackage *aCodec = 0,
					TMdaPackage *aExtra = 0 );

	/**
	 * ͨ���ļ�·������url��ת��ͼƬ
	 */
	void
			OpenFileL (const TDesC &aFileName, TBool aNeedMasked = EFalse, 
					TMdaClipFormat *aFormat = 0, TMdaPackage *aCodec = 0, 
					TMdaPackage *aExtra = 0 );

	/**
	 * ��ȡBitmap������
	 * ���ת��δ��ɷ���ΪNULL,�����ʹ��ʱ�����ָ���ж���α
	 */
	CFbsBitmap* GetBitmap ();

	/**
	 * ��ȡMasked Bitmap������
	 * ���ת��δ��ɷ���ΪNULL,�����ʹ��ʱ�����ָ���ж���α
	 */
	CFbsBitmap* GetBitmapMasked ();

	/**
	 * ������ MMdaImageUtilObserver: 
	 */
	void MiuoConvertComplete (TInt aError );
	void MiuoCreateComplete (TInt aError );
	void MiuoOpenComplete (TInt aError );

	/**
	 * WebClientEvent()
	 * Called when event occurs in CWebClientEngine.
	 * @param aEventDescription: A event in textual format, e.g.
	 *                           "Transaction Successful"
	 */
	void WebClientEvent (const TInt aEvent, 
			TInt aSessionId, TInt aCode = 0 );

	/**
	 * WebClientHeaderReceived()
	 * Called when HTTP header is received.
	 * @param aHeaderData: Header field name and value
	 */
	void WebClientHeaderReceived (const TDesC8& aHeaderFiled, const TDesC8& aHeaderVal,TInt aSessionId );

	/**
	 * WebClientBodyReceivedComplete()
	 * Called when a part of the HTTP body is received.
	 * @param aBodyData:  Part of the body data received. (e.g. part of
	 *                    the received HTML page)
	 */
	void WebClientBodyReceivedComplete (const TDesC8& aBodyData, 
			TInt aSessionId ) ;
	
	/**
	 * 
	 */
	void ClientBodyReceived (const TDesC8& aBodyData, TBool aIsLast );

private:
	
	/**
	 * EPOC default constructor for performing 2nd stage construction
	 */
	void ConstructL ();

private:
	CMdaImageDataReadUtility* m_pImageUtility;//ͼ��������
	CFbsBitmap* m_pBitmap; //ͼ������Bitmap
	CFbsBitmap* m_pBitmapMask; //Maskλͼ
	TBool m_flagConvert; //ת����ɱ��
	TBool m_flagMask; //��ҪmaskͼƬ���

	MMulImageObserver* m_pObserver;
	TFileName m_cacheFile; //ͼƬ����·��
	TInt 	  m_querySession;

};

#endif // MULIMAGE_H
